/*
* Author        Vo Tuan Anh
* Email         votuananhs@gmail.com
* Brief         This library controls the LCD 16x2, model 4 bit data.
*               And developing on CMSIS v3.20 library for LPC17xx
*/

#ifndef _LCD16X2_4BIT_H_
#define _LCD16X2_4BIT_H_

#ifdef __cplusplus
extern "C" {
#endif
  
#include "LPC17xx.h"
#include "lpc_types.h"
#include "lpc17xx_gpio.h"

#define PORT_LCD16X2    2       /* using port 2 of LPC1768 on HY-LandTiger board */
                                /* you can change it if you want */
#define START_PIN       0       /* this value  */
#define RS_LCD16X2      (0x00000001 << START_PIN)
#define RW_LCD16X2      (RS_LCD16X2 << 1)
#define EN_LCD16X2      (RS_LCD16X2 << 2)
#define DIR_74HC245_LCD16X2     (RS_LCD16X2 << 3) /* this pin control the direction of 74HC245 ic */
#define MASK_DATA_LCD16X2       ((RS_LCD16X2 << 4)|(RS_LCD16X2 << 5)|(RS_LCD16X2 << 6)|(RS_LCD16X2 << 7))


uint8_t WriteDataToPort_LPC1768(uint32_t u32Data);

uint8_t CheckFlag_LCD16x2(void);
uint8_t ReadData4Bit_LCD16x2(void);
uint8_t WriteData4Bit_LCD16x2(uint8_t u8Data);
uint8_t ReadData_LCD16x2(void);
uint8_t WriteData_LCD16x2(uint8_t u8Data);
uint8_t WriteCommand_LCD16x2(uint8_t u8Command);
uint8_t PositionPoint_LCD16x2(uint8_t u8Pos_X, uint8_t u8Pos_Y);
uint8_t PrintString_LCD16x2(uint8_t u8Pos_X, uint8_t u8Pos_Y, uint8_t *u8Str);
uint8_t InitMode4Bit_LCD16x2(void);

#ifdef __cplusplus
}
#endif
#endif /* _LCD16X2_4BIT_H_ */